<template>
  <div class="newschedule-container" @click.stop="()=>{}">
    <Dialogdrawerdefect
      :ddtvisible.sync="dialogVisible"
      :title="tempTitle"
      size="960px"
      :modal="true"
      :before-close="close"
    >
      <div class="sche_navs">
        <div class="btn" v-show="formdata.id && formdata.appointmentStatus==='正常预约' && formdata.callNum" @click="appoDetail">预约详情 <i class="el-icon-arrow-right"></i></div>
      </div>
      <div class="nsc-wrap" v-loading="loading">
        <div class="nsc-h">
          <el-form
            ref="formdata"
            :inline="true"
            :model="formdata"
            @submit.native.prevent
            class="ky-form-inline ky-form-inline-sm">
            <el-form-item label="时间">
              <el-input v-model="mmm" style="position: fixed; left: 1000000px;top:0;height: 1px;opacity: 0;"></el-input>
              <el-time-select
                ref="timeselect_start"
                placeholder="起始时间"
                v-model="formdata.beginTime"
                :picker-options="startTimePickerOption"
                :disabled="checkMore"
              >
              </el-time-select>
              <el-time-select
                ref="timeselect_end"
                placeholder="结束时间"
                v-model="formdata.endTime"
                :picker-options="endTimePickerOption"
                :disabled="checkMore"
              >
              </el-time-select>
            </el-form-item>
            <el-form-item label="时段状态" v-if="templateType === 'schedule'">
              <el-select size="mini" :disabled="checkMore" v-model="formdata.appointmentStatus" placeholder="请选择">
                <el-option
                  v-for="item in appointmentStatusOptions"
                  :key="item"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="状态" v-if="templateType === 'template'">
              <el-select size="mini" :disabled="checkMore" v-model="formdata.status" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in statusOptions"
                  :key="item"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="颜色:">
              <public-input-color-picker
                :value="formdata.color"
                :show-input="false"
                placeholder="请选择颜色"
                @change="(val)=>{formdata.color=val}"
              />
            </el-form-item>
            <br/>
            <el-form-item label="号源数">
              <el-input ref="checkNum" :disabled="checkMore" v-model="formdata.checkNum" @keyup.native="validNumber('checkNum')" clearable placeholder="请输入" maxlength="4" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item label="预留">
              <div slot="label">预留
                <el-tooltip class="item" :disabled="checkMore" effect="dark" content="预留号只允许前台登记用，临床预约或移动预约等不能使用会过滤掉！" placement="top-end">
                  <i class="el-icon-warning"></i>
                </el-tooltip>
              </div>
              <el-input ref="reserveNum" :disabled="checkMore" v-model="formdata.reserveNum" @keyup.native="validNumber('reserveNum')" clearable placeholder="请输入" maxlength="4" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item label="追加">
              <el-input ref="addNum" :disabled="checkMore" v-model="formdata.addNum" @keyup.native="validNumber('addNum')" clearable placeholder="请输入" maxlength="4" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item>
              <div slot="label">起始号码
                <el-tooltip class="item" :disabled="checkMore" effect="dark" content="起始号码如果比同班次前面的号源小，会自动计算衔接于前面的号源数！" placement="top-start">
                  <i class="el-icon-warning"></i>
                </el-tooltip>
              </div>
              <el-input ref="initialNum" :disabled="checkMore" v-model="formdata.initialNum" @keyup.native="validNumber('initialNum')" clearable placeholder="请输入" maxlength="4" style="width: 80px;"></el-input>
            </el-form-item>
            <el-form-item label="已预约:" v-if="templateType === 'schedule' && formdata.appointmentStatus ==='正常预约' || formdata.callNum">
              <b style="line-height: 36px;">{{formdata.callNum}}</b>
            </el-form-item>
          </el-form>
        </div>
        <div class="ky-divider"><el-divider></el-divider></div>
        <div class="nsc-m" v-show="dialogVisible">
          <!-- <div class="nsc-m-tit">参数设置</div> -->
          <el-row :gutter="15">
            <el-col :span="6">
              <templateList ref="templateList" @checkedTemplate="checkedTemplate"></templateList>
            </el-col>
            <el-col :span="18">
              <ruleTemplate ref="ruleTemplate" :hospital-code="hospitalCode" :dep="dep"></ruleTemplate>
            </el-col>
          </el-row>
        </div>
        <div class="nsc-footer">
          <el-checkbox style="float:left;margin-top:6px;" v-model="appoContinuation" @change="continuationChange">班次起始号码连续
            <el-tooltip class="item" effect="dark" content="班次起始号码连续：如果修改号源时段的起始号码变小，且修改后的起始号码需大于上一个时段的截至号码，后面的时段号源同步修改起始号码！如果修改后的号码小于上一个时段的截止号码，则自动计为上一个时段的号码延续！！" placement="top-start">
              <i class="el-icon-warning"></i>
            </el-tooltip>
          </el-checkbox>
          <el-button size="small" @click="close">返回</el-button>
          <el-button size="small" v-if="templateType === 'schedule'" @click="sourceInfoOpen">锁定号源</el-button>
          <el-button size="small" type="warning" @click="handleLog" v-if="formdata.id">日志</el-button>
          <el-button size="small" @click="openAddTemp" v-if="templateType === 'schedule'" v-permission="['YJYY10001001002', 'YJYY10008002001']">添加参数模板</el-button>
          <el-button size="small" @click="openAddTemp" v-if="templateType === 'template'" v-permission="'YJYY10002031001'">添加参数模板</el-button>
          <el-button size="small" type="primary" @click="save" v-if="templateType === 'schedule'" v-permission="['YJYY10001001002', 'YJYY10008002001']">确定</el-button>
          <el-button size="small" type="primary" @click="save" v-if="templateType === 'template'" v-permission="'YJYY10002031001'">确定</el-button>
        </div>
      </div>
    </Dialogdrawerdefect>
    <!-- 模板名称 -->
    <el-dialog
      title="参数名称"
      :visible.sync="dialogVisibleTemp"
      :destroy-on-close="true"
      width="400px">
      <div>
        <el-form
          :inline="true"
          :model="formdata"
          class="ky-form-inline ky-form-inline-sm">
          <el-form-item label="参数名称：">
            <el-input v-model="formdata.templateName" placeholder="请输入"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogVisibleTemp = false">取 消</el-button>
        <el-button size="small" type="primary" @click="tempAddSend">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 时段日志 -->
    <appoPeriodLog
      v-if="isShowAppoPeriodLog"
      :hospital-code="hospitalCode"
      :appo-period-log-dlg.sync="appoPeriodLogDlg"
      :destroy-on-close="true"
      :id="appoLogId"
      :tabel-type="tabelType"
    ></appoPeriodLog>
    <!-- 预约列表 -->
    <appoInfoDetail ref="appoInfoDetail" v-if="isShowAppoInfoDetail"></appoInfoDetail>
  </div>
</template>

<script>
import {
  getCalTimeMinute
} from '@/utils/schedule'
import { addAppointmentParamsTemp } from '@/api/room'
import Dialogdrawerdefect from '@/components/dialogbox/dialogDrawerDefect'
import appoPeriodLog from '@/components/logDialog/appoPeriodLog'
import publicInputColorPicker from '@/components/color-picker/index'
import ruleTemplate from './ruleTemplate'
import appoInfoDetail from './appoInfoDetail'
import templateList from './templateList'
import { Options } from '@/utils/constant'
// import { mapGetters } from 'vuex'
let _formdata = {
  id: 0,
  beginTime: '',
  endTime: '',
  addNum: '0', // 追加
  reserveNum: '0', // 预留号码
  recordCode: '', // 模板标题
  templateName: '', // 添加到参数模板的模板标题
  initialNum: '', // 初始号码
  startNum: '', // 初始号码
  checkNum: '', // 检查数量
  appointmentFilters: [], // 过来规则
  channel: [],
  check: [],
  status: '启用', // 状态
  color: '', // 颜色
  appointmentStatus: '计划排班'
}
export default {
  inject: ['tempListUpdate'],
  props: {
    hospitalCode: {
      type: String,
      default: ''
    },
    isOpenDialog: {
      type: Boolean,
      default: false
    },
    tempTitle: {
      type: String,
      default: '新增号源'
    },
    templateType: {
      type: String,
      default: 'schedule' // schedule、template
    },
    tabelType: {
      type: String,
      default: '1'
    }
  },
  components: {
    Dialogdrawerdefect,
    ruleTemplate,
    templateList,
    appoPeriodLog,
    appoInfoDetail,
    publicInputColorPicker
  },
  data() {
    return {
      isShowAppoPeriodLog: false,
      isShowAppoInfoDetail: false,
      checkMore: false,
      // ISUSE_DEFAULTSTEPTIME: window.g.ISUSE_DEFAULTSTEPTIME || false,
      appoContinuation: false,
      loading: false,
      // tempVisible: false,
      stfIsAdd: true, // false 编辑，默认 true 新增
      mmm: '', // 所在输入框，解决模态框打开是获取焦点的bug
      stfStatus: 'schedule', // 判断弹框模板使用的对象，schedule 排班管理，template 模板管理
      // 设置时间选项参数
      minMaxNum: null,
      timeSel: '',
      stepTime: window.g.DEFAULTSTEPTIME || '00:30',
      startTime: '08:00',
      endTime: '12:00',
      formdata: {
        id: 0,
        beginTime: '',
        endTime: '',
        addNum: '', // 追加
        reserveNum: '', // 预留号码
        recordCode: '', // 模板标题，
        templateName: '', // 添加到参数模板的模板标题
        initialNum: '', // 初始号码
        startNum: '', // 初始号码
        checkNum: '', // 检查数量
        status: '', // 状态
        appointmentStatus: '',
        color: '', // 颜色
        appointmentFilters: [
          // {
          //   parametersType: '',
          //   parametersValues: '',
          //   parametersName: ''
          // }
        ], // 过来规则
        channel: [],
        check: []
      },
      appointmentStatusOptions: Options.appointmentStatusOptions,
      statusOptions: ['启用', '停用'],
      // 检查项目
      // hospitalCode: '',
      dep: '',
      // 模板
      checkroom: [],
      tempObj: null,
      // 新增快捷参数模板
      dialogVisibleTemp: false,
      // 操作日志
      appoPeriodLogDlg: false,
      appoLogId: null
    }
  },
  computed: {
    // ...mapGetters(['tempVisible']),
    dialogVisible: {
      get() {
        return this.isOpenDialog
      },
      set(val) {
        this.$emit('update:isOpenDialog', val)
      }
    },
    appConfig() {
      return this.$store.state.settings.appConfig
    },
    ISUSE_DEFAULTSTEPTIME() {
      return (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.ISUSE_DEFAULTSTEPTIME) || window.g.ISUSE_DEFAULTSTEPTIME || false
    },
    // stepTime() {
    //   return (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.DEFAULTSTEPTIME) || window.g.DEFAULTSTEPTIME || '00:30',
    // },
    startTimePickerOption() {
      // // console.log('startTimePickerOption', this.endTime)
      return {
        start: this.startTime,
        end: this.endTime,
        step: this.stepTime
        // end: this.formdata.endTime ? this.formdata.endTime : this.endTime,
        // maxTime: '24:00'// this.formdata.endTime
      }
    },
    endTimePickerOption() {
      // // console.log('endTimePickerOption', this.endTime)
      return {
        start: this.startTime,
        end: this.endTime,
        step: this.stepTime
        // minTime: this.formdata.beginTime
        // maxTime: '24:00'// this.formdata.endTime
      }
    }
  },
  created() {
    console.log('created=>scheduleTemplateForm')
  },
  beforeDestroy() {
    console.log('beforeDestroy=>scheduleTemplateForm')
  },
  methods: {
    // focusStartTime(data) {
    //   // // console.log('focusStartTime', this.timeSel)
    //   this.startTime = this.timeSel.split('-')[0]
    //   this.endTime = this.timeSel.split('-')[1]
    // },
    // focusEndTime(data) {
    //   // // console.log('focusEndTime', this.formdata.beginTime)
    //   this.startTime = this.formdata.beginTime
    // },
    sourceInfoOpen() {
      this.$emit('openSourceInfoDialog', this.formdata)
    },
    resetForm() {
      this.formdata = {
        id: 0,
        beginTime: '',
        endTime: '',
        addNum: '', // 追加
        reserveNum: '', // 预留号码
        recordCode: '', // 模板标题，
        templateName: '', // 添加到参数模板的模板标题
        initialNum: '', // 初始号码
        startNum: '', // 初始号码
        checkNum: '', // 检查数量
        status: '', // 状态
        appointmentStatus: '',
        color: '', // 颜色
        appointmentFilters: [
          // {
          //   parametersType: '',
          //   parametersValues: '',
          //   parametersName: ''
          // }
        ], // 过来规则
        channel: [],
        check: []
      }
      _formdata = {
        id: 0,
        beginTime: '',
        endTime: '',
        addNum: '0', // 追加
        reserveNum: '0', // 预留号码
        recordCode: '', // 模板标题
        templateName: '', // 添加到参数模板的模板标题
        initialNum: '', // 初始号码
        startNum: '', // 初始号码
        checkNum: '', // 检查数量
        appointmentFilters: [], // 过来规则
        channel: [],
        check: [],
        status: '启用', // 状态
        color: '', // 颜色
        appointmentStatus: '计划排班'
      }
      console.log('this.formdata', this.formdata)
    },
    async init(data) {
      console.log('待查看=>scheduleTemplateForm=>init_data', data)
      // // console.log('init_data data.beginTime', data.beginTime)
      // time, minMaxNum
      let { appoInfo, room, step, startNum, timeSel, minMaxNum, time, checkMore } = data
      console.log('init=>appoInfo', JSON.stringify(appoInfo))
      // 是否选择了多条号源数据
      this.checkMore = checkMore
      // // console.log('room', JSON.stringify(room))
      // room ["47000593033030211A1001","龙湾院区","SALT-DEP-CT","SALT-MTYPE-CT","龙湾-测试CT2$#CT"]
      this.timeSel = timeSel
      // // console.log('this.timeSel111', this.timeSel)
      this.minMaxNum = minMaxNum || null
      // // console.log('this.minMaxNum_in sceduleTemplateForm', this.minMaxNum)
      if (appoInfo) {
        this.stfIsAdd = false
      } else {
        this.stfIsAdd = true
      }
      let appConfig = this.$store.state.settings.appConfig
      if (this.ISUSE_DEFAULTSTEPTIME) {
        // console.log('appConfig.baseConfig.DEFAULTSTEPTIME', appConfig.baseConfig.DEFAULTSTEPTIME)
        this.stepTime = (appConfig && appConfig.baseConfig && appConfig.baseConfig.DEFAULTSTEPTIME) || '00:30'
        // console.log('this.stepTime=>1', this.stepTime)
      }
      // 重置数据
      let _fd = _formdata // JSON.parse(JSON.stringify(_formdata))
      // // console.log('this.stepTime初始化', this.stepTime)
      if (this.ISUSE_DEFAULTSTEPTIME) {
        // this.stepTime = this.stepTime
      } else {
        this.stepTime = step ? `00:${step}` : this.stepTime
      }
      this.startTime = this.getEndTimeM(time ? time.split('-')[0] : '00:00')
      // // console.log('end_time', time)
      // 每次打开编辑弹窗的时候，把时间选择框的截止时间重置为24:00，实施那边的需求，部分医院有其他说法，可让他们手动填写（支持手动填写时间）
      this.endTime = '24:00' // this.getEndTimeM(time ? time.split('-')[1] : '24:00')
      // this.startTime = this.getEndTimeM(time ? time.split('-')[0] : '00:00')
      // this.endTime = this.getEndTimeM(time ? time.split('-')[1] : '24:00')
      this.formdata = appoInfo ? Object.assign(_fd, appoInfo) : Object.assign({}, _fd)
      console.log('init=>this.formdata', JSON.stringify(this.formdata))
      this.formdata.initialNum = appoInfo ? this.formdata.initialNum : this.minMaxNum && this.minMaxNum.minNum > 0 ? this.minMaxNum.minNum : startNum
      this.formdata.startNum = startNum
      console.log('this.formdata.beginTime', this.formdata.beginTime)
      console.log('timeSel', timeSel)
      this.formdata.beginTime = this.getEndTimeM(this.formdata.beginTime ? this.formdata.beginTime : timeSel ? timeSel.split('-')[0] : '')
      console.log('###this.formdata.beginTime###时间之初', this.formdata.beginTime)
      this.formdata.endTime = this.getEndTimeM((data.appoInfo && data.appoInfo.isBad) ? data.appoInfo.oldEndTime.substr(0, 5) : this.formdata.endTime ? this.formdata.endTime : timeSel ? timeSel.split('-')[1] : '') // 20231103修改
      // this.formdata.endTime = this.getEndTimeM(this.formdata.endTime ? this.formdata.endTime : timeSel ? timeSel.split('-')[1] : '') // 原来的代码
      console.log('###this.formdata.endTime###时间结果', this.formdata.endTime)
      this.checkroom = [...room]
      // this.hospitalCode = room.length > 0 ? room[0] : ''
      // room ["47000593033030211A1001","龙湾院区","SALT-DEP-CT","SALT-MTYPE-CT","龙湾-测试CT2$#CT"]
      this.dep = room.length > 0 ? room[2] : ''
      // // console.log('this.dep=>1', this.dep)
      // this.tempVisible = true
      // this.$store.dispatch('app/toggleTempVisible', true)
      this.tempObj = null
      setTimeout(() => {
        this.$refs.templateList && this.$refs.templateList.init(this.checkroom)
        console.log('==this.formdata==ruleTemplate==', JSON.stringify(this.formdata))
        this.$refs.ruleTemplate && this.$refs.ruleTemplate.init(this.formdata)
      }, 200)
    },
    // 保存
    async save() {
      if (this.validForm()) {
        if (getCalTimeMinute(this.formdata.beginTime) >= getCalTimeMinute(this.formdata.endTime)) {
          this.$confirm(`温馨提示：开始时间${this.formdata.beginTime}不能大于等于结束时间${this.formdata.endTime}，否则将会保存失败，请修正时间后再来确定！`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then((e) => {
            // // console.log('e', e)
            if (e == 'confirm') {
              console.log('e', e)
            } else {
              // // console.log('cancel')
            }
          }).catch(() => {})
        } else {
          if (this.formdata.beginTime < this.timeSel.split('-')[0]) {
            this.$confirm(`温馨提示：该时间段的号源所设置的开始时间应该在${this.timeSel}之间，否则将会保存失败，请修正时间后再来确定！`, '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then((e) => {
              // // console.log('e', e)
              if (e == 'confirm') {
                // //
              } else {
                // // console.log('cancel')
              }
            }).catch(() => {})
          } else {
            // // console.log('this.minMaxNum', this.minMaxNum)
            if (this.minMaxNum) {
              const total = (this.formdata.initialNum * 1) + (this.formdata.checkNum * 1) + (this.formdata.reserveNum * 1) + (this.formdata.addNum * 1)
              // // console.log('total', total)
              // // console.log('this.minMaxNum.minNum', this.minMaxNum.minNum)
              // // console.log('this.formdata.initialNum', this.formdata.initialNum)
              if (this.formdata.initialNum < this.minMaxNum.minNum) {
                this.$message.warning(`起始号码需大于上一个时段最大号源号码 ${this.minMaxNum.minNum - 1}！`)
                return
              }
              if (this.minMaxNum.maxNum != 0 && this.minMaxNum.maxNum < total) {
                this.$confirm(`设置的最大号源号码 ${total} 大于下一个时段起始号码 ${this.minMaxNum.maxNum}，后面的时段起始号码会相应变化， 是否继续?`, '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  this.saveSend()
                }).catch(() => {})
              } else {
                this.saveSend()
              }
            } else {
              this.saveSend()
            }
          }
        }
      }
    },
    // 弹窗中的保存按钮被点击，触发保存事件saveSend
    async saveSend() {
      // // console.log('+++++++++++++++++++++++++++++++++弹窗中的保存按钮被点击，触发保存事件saveSend+++++++++++++++++++++++++++++++++++++')
      let ruleParams = await this.$refs.ruleTemplate.getRuleData()
      ruleParams = JSON.parse(ruleParams)
      console.log('查看ruleParams', ruleParams)
      // console.log('this.stfIsAdd', this.stfIsAdd)
      if (this.stfIsAdd) {
        // 新增
        const _obj = {
          'beginTime': this.getEndTime(this.formdata.beginTime), // 检查开始时间
          'endTime': this.getEndTime(this.formdata.endTime), // 检查结束时间
          'initialNum': this.formdata.initialNum * 1, // 初始号码
          'checkNum': this.formdata.checkNum * 1, // 检查数量
          'reserveNum': this.formdata.reserveNum * 1, // 预留数量
          'addNum': this.formdata.addNum * 1, // 追加数量
          'status': this.formdata.status, // 模板状态
          'color': this.formdata.color, // 颜色
          'appointmentStatus': this.formdata.appointmentStatus, // 时段状态
          'appointmentFilters': [...ruleParams.appointmentFilters]
        }
        this.$emit('addScheduleTempSave', _obj)
        // this.$store.dispatch('app/toggleTempVisible', false)
      } else {
        // 编辑
        const _obj = { ...this.formdata }
        _obj.beginTime = this.getEndTime(this.formdata.beginTime)
        _obj.endTime = this.getEndTime(this.formdata.endTime)
        _obj.reserveNum = _obj.reserveNum * 1
        _obj.initialNum = _obj.initialNum * 1
        _obj.addNum = _obj.addNum * 1
        _obj.checkNum = _obj.checkNum * 1
        _obj.appointmentFilters = [...ruleParams.appointmentFilters]
        this.$emit('editScheduleTempSave', _obj)
      }
      this.dialogVisible = false
    },
    // 必填选项验证
    validForm() {
      if (!this.formdata.beginTime) {
        this.$message.warning('请选择开始时间！')
        this.$refs.timeselect_start.focus()
        return false
      } else if (!this.formdata.endTime) {
        this.$message.warning('请选择结束时间！')
        this.$refs.timeselect_end.focus()
        return false
      } else if (!this.formdata.checkNum && this.formdata.checkNum !== 0) {
        this.$message.warning('请输入号源数量！')
        this.$refs.checkNum.focus()
        return false
      } else if (!this.formdata.reserveNum && this.formdata.reserveNum !== 0) {
        this.$message.warning('请输入预留数量！')
        this.$refs.reserveNum.focus()
        return false
      } else if (this.formdata.initialNum < this.formdata.startNum) {
        this.$message.warning(`初始号码不能小于${this.formdata.startNum}（时令班次设置的起始号码）！`)
        this.$refs.initialNum.focus()
        return false
      }
      return true
    },
    // 数据仅可输入数字判断
    validNumber(keyVal) {
      this.formdata[keyVal] = this.formdata[keyVal] ? this.formdata[keyVal].replace(/[^\d]/g, '') : this.formdata[keyVal]
    },
    // 添加到参数模板，弹框
    openAddTemp() {
      if (this.validForm()) {
        this.dialogVisibleTemp = true
      }
    },
    // 新增参数模板
    async tempAddSend() {
      if (!this.formdata.templateName) {
        this.$message.warning('请输入参数模板名称！')
        return false
      }
      let ruleParams = await this.$refs.ruleTemplate.getRuleData()
      ruleParams = JSON.parse(ruleParams)

      const temp = {
        hospitalCode: this.checkroom[0],
        depArea: this.checkroom[1],
        dep: this.checkroom[2],
        ModalityType: this.checkroom[3],
        CheckRoom: this.checkroom[4],
        addNum: this.formdata.addNum * 1,
        beginTime: this.getEndTime(this.formdata.beginTime),
        endTime: this.getEndTime(this.formdata.endTime),
        checkNum: this.formdata.checkNum * 1,
        reserveNum: this.formdata.reserveNum * 1,
        recordCode: this.formdata.templateName,
        appointmentFilters: [...ruleParams.appointmentFilters]
      }
      await addAppointmentParamsTemp(temp)
      this.dialogVisibleTemp = false
      this.formdata.templateName = ''
      this.$refs.templateList && this.$refs.templateList.init(this.checkroom, true)
      // 父级 provide 方法 更新快速选择参数模板的列表数据
      this.tempListUpdate()
    },

    continuationChange() {
      this.$store.dispatch('user/continuationChange', this.appoContinuation)
    },
    // 预约详情
    appoDetail() {
      this.isShowAppoInfoDetail = true
      this.$nextTick(() => {
        const params = {
          HospitalCode: this.checkroom[0],
          AppointmentListDmbId: this.formdata.id
        }
        this.$refs.appoInfoDetail.init(params)
      })
    },

    // 退出
    close() {
      this.dialogVisible = false
      this.resetForm()
      console.log('resetForm')
      // this.$store.dispatch('app/toggleTempVisible', false)
      this.$emit('closeTempDlg')
    },

    // 模板选择
    checkedTemplate(temObj) {
      this.tempObj = temObj
      // // console.log('checkedTemplate:====', this.tempObj)
      this.$refs.ruleTemplate && this.$refs.ruleTemplate.resetInit(this.tempObj)
    },
    // 时段日志
    handleLog() {
      this.isShowAppoPeriodLog = true
      this.appoLogId = this.formdata.id + ''
      this.$nextTick(() => {
        this.appoPeriodLogDlg = true
      })
    },
    // 判断是否位24点，如果24点，则转为 23：59
    getEndTime(time) {
      if (!time) return ''
      const t = time.split(':')
      return t[0] * 1 === 24 ? '23:59' : time
    },
    getEndTimeM(time) {
      return time === '23:59' ? '24:00' : time
    }
  }
}
</script>

<style lang="scss" scoped>
.nsc-wrap{
  height: 100%;
  display: flex;
  flex-direction: column;
  // min-width: 600px;
  padding: 0 20px;
  /deep/ .el-date-editor.el-input, .el-date-editor.el-input__inner{
    width: 120px;
  }
  /deep/ .el-form-item__label{
    font-weight: 500;
  }
  .nsc-m{
    padding:0px 0 54px;
    flex: 1;
    position: relative;
    .nsc-m-tit{
      font-size: 14px;
      font-weight: bold;
      padding: 4px 0;
    }
  }
  .nsc-footer{
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    text-align: right;
    padding: 10px 20px;
    border-top: solid 1px #DCDFE6;
    background-color: #fff;
  }
}
.sche_navs{
  position: absolute;
  top: 15px;
  right: 15px;
  cursor: pointer;
  user-select: none;
  .btn:hover{
    color: #00C0EF
  }
}
</style>
